package com.lagou.niancheng.work2.server;

import com.lagou.niancheng.work2.api.Work2DubboApi;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

@Service
public class Work2DubboApiServer implements Work2DubboApi {

    @Override
    public void method1() {
        sleepRandom();
    }

    @Override
    public void method2() {
        sleepRandom();
    }

    @Override
    public void method3() {
        sleepRandom();
    }


    private Random random = new Random();

    private void sleepRandom() {
        int millis = random.nextInt(100);
        try {
            TimeUnit.MILLISECONDS.sleep(millis);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
